﻿@using MvcSample.Web.Models
@model User
@{
    ViewBag.Title = "Home Page";
    string nullValue = null;

    ViewBag.Anon = new
    {
        Name = "FirstName LastName",
        Address = new { Street = "123 Fake St.", City = "Redmond", State = "WA", Country = "USA", },
    };
}

@section header {
    <style type="text/css">
        #qux {
            display: none;
        }

            #qux.foo {
                color: red;
            }
    </style>
}

@section footer {
    <script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
    <script>
        $(function () {
            $("#qux").fadeIn(3000, function () {
                $(this).addClass("foo")
            });
        });
    </script>
}

@functions {
    public Task<string> AsyncValueRetrieval()
    {
        return Task.FromResult("Hello World");
    }

    public Task RenderHelloWorldPartial(User model)
    {
        // Imagine this method was a super complex method that was used as a helper method.
        return Html.RenderPartialAsync("HelloWorldPartial", model);
    }
}

<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more &raquo;</a></p>
    <h3 style="color: red">@ViewBag.TempData<br/>@TempData["tempData"]</h3>
    File Upload Demo: <br/>
    <form action="Home/PostFile" method="post" enctype="multipart/form-data">
        <input type="file" name="files" id="file1" />
        <input type="file" name="files" id="file2" />
        <input type="submit" value="submit" />
    </form>
</div>
<div class="row">
    <h3 title="@(Model?.Name)" class="@nullValue">Hello @Html.DisplayTextFor(User => User)! Happy @(Model?.Age) birthday.</h3>
    <h3 id="qux">This value was retrieved asynchronously: @(await AsyncValueRetrieval())</h3>
    <h3>Partial Async: @await Html.PartialAsync("HelloWorldPartial", Model)</h3>
    <h3>
        Render Partial Async (Custom model): @{ await RenderHelloWorldPartial(new User()
                                                {
                                                    Name="Bob"
                                                });
        }
    </h3>

    <div class="col-md-4">
        <h2>Book a flight</h2>
        <p>
            Go to our cool travel reservation system.
        </p>
        <p>@Html.ActionLink("Reserve Now", "Fly", "Flight", new { area = "Travel" }, new { @class = "btn btn-default" })</p>
    </div>
    <div class="col-md-4">
        <h2>Get more libraries</h2>
        <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Web Hosting</h2>
        <p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
    </div>
</div>

<div class="row">
    <div style="float: left; border: 5px solid blue; margin: 5px; padding: 7px;">
        <table>
            <tr>
                <td>
                    @Html.LabelForModel("ForModel")
                </td>
                <td>
                    '@Html.DisplayNameForModel()'
                </td>
                <td>
                    '@Html.NameForModel()'
                </td>
                <td>
                    '@Html.ValueForModel()'
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Name")
                </td>
                <td>
                    '@Html.DisplayName("Name")'
                </td>
                <td>
                    '@Html.Name("Name")'
                </td>
                <td>
                    '@Html.Value("Name")'
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(m => m.Address)
                </td>
                <td>
                    '@Html.DisplayNameFor(m => m.Address)'
                </td>
                <td>
                    '@Html.NameFor(m => m.Address)'
                </td>
                <td>
                    '@Html.ValueFor(m => m.Address)'
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Anon.Address.Street")
                </td>
                <td>
                    '@Html.DisplayName("Anon.Address.Street")'
                </td>
                <td>
                    '@Html.Name("Anon.Address.Street")'
                </td>
                <td>
                    '@Html.Value("Anon.Address.Street")'
                </td>
            </tr>
        </table>
    </div>
    <div style="float: left; border: 5px solid red; margin: 5px;">
        <p>Tags from View():</p>
        @await Component.InvokeAsync("Tags", 5, "View")
        <p>Tags from Content():</p>
        <p>@await Component.InvokeAsync("Tags", 5, "Content")</p>
        <p>Tags from Json():</p>
        <p>@await Component.InvokeAsync("Tags", 5, "Json")</p>
        <p style="padding: 0px 10px;">'@ViewBag.Title' should match page heading (still)</p>
    </div>
    <div style="float: left; border: thick solid lightskyblue; margin: 5px; padding: 7px;">
        @using (Html.BeginForm())
        {
            @Html.HiddenFor(m => m.Age)
            <table>
                <tr>
                    <td>
                        @Html.Label("Name")
                    </td>
                    <td>
                        @Html.TextBox("Name")
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(m => m.Address, htmlAttributes: new { @class="control-label col-md-2" })
                    </td>
                    <td>
                        @Html.TextBoxFor(m => m.Address, htmlAttributes: new { @class = "form-control" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Alive")
                    </td>
                    <td>
                        @Html.CheckBox("Alive")
                        or
                        @Html.RadioButton("Alive", value: false) False
                        @Html.RadioButton("Alive", value: true) True
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(m => m.Dependent.Alive)
                    </td>
                    <td>
                        @Html.CheckBoxFor(m => m.Dependent.Alive)
                        or
                        @Html.RadioButtonFor(m => m.Dependent.Alive, value: false) False
                        @Html.RadioButtonFor(m => m.Dependent.Alive, value: true) True
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.Password, htmlAttributes: new { @class="control-label col-md-2" })
                    </td>
                    <td>
                        @Html.PasswordFor(m => m.Password, htmlAttributes: new { @class = "form-control" })
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="Save" class="btn btn-default" style="margin-left: 10px" />
                    </td>
                    <td></td>
                </tr>
            </table>
        }
        @{ Html.BeginForm(method: FormMethod.Post, htmlAttributes: new { someAttribute = "some value", }); }
            @Html.Hidden("Anon.Id")
            <table>
                <tr>
                    <td>
                        @Html.Label("Anon.Name")
                    </td>
                    <td>
                        @Html.TextBox("Anon.Name")
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Anon.Address.Street")
                    </td>
                    <td>
                        @Html.TextBox("Anon.Address.Street", (object)ViewBag.Anon.Address.Street)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Anon.Address.City")
                    </td>
                    <td>
                        @Html.TextBox("Anon.Address.City", value: null, format: "{0} (3)")
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Anon.Address.State")
                    </td>
                    <td>
                        @Html.TextBox("Anon.Address.State", value: null, htmlAttributes: new { @class = "form-control" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Anon.Address.Country")
                    </td>
                    <td>
                        @Html.TextBox("Anon.Address.Country", value: null, format: "{0} (4)",
                                          htmlAttributes: new { @class = "form-control" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.Label("Password")
                    </td>
                    <td>
                        @Html.Password("Password", "some string")
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="submit" value="Save" class="btn btn-default" style="margin-left: 10px" />
                    </td>
                    <td></td>
                </tr>
            </table>
        @{ Html.EndForm(); }
    </div>
    <div style="float: left; border: 5px solid lightgreen; margin: 5px; padding: 7px;">
        @using (Html.BeginForm(controllerName: "Home", actionName: "Edit", method: FormMethod.Post))
        {
        <table>
            <tr>
                <td>
                    @Html.Label("Name", "Display / Edit Name")
                </td>
                <td>
                    '@Html.Display("Name")'
                </td>
                <td>
                    @Html.Editor("Name")
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Dependent.Name", "Display / Edit Dependent.Name")
                </td>
                <td>
                    '@Html.Display("Dependent.Name")'
                </td>
                <td>
                    @Html.Editor("Dependent.Name")
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Alive", "Display / Edit Alive")
                </td>
                <td>
                    '@Html.Display("Alive")'
                </td>
                <td>
                    @Html.Editor("Alive")
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Dependent.Alive", "Display / Edit Dependent.Alive")
                </td>
                <td>
                    '@Html.Display("Dependent.Alive")'
                </td>
                <td>
                    @Html.Editor("Dependent.Alive")
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Age", "Display / Edit Age")
                </td>
                <td>
                    '@Html.Display("Age")'
                </td>
                <td>
                    @Html.Editor("Age")
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("GPA", "Display / Edit GPA")
                </td>
                <td>
                    '@Html.Display("GPA")'
                </td>
                <td>
                    @Html.Editor("GPA")
                </td>
            </tr>
        </table>
        }
    </div>
    <div style="float: left; border: 5px dashed green; margin: 5px; padding: 7px;">
        @using (Html.BeginForm(controllerName: "Home", actionName: "Edit", method: FormMethod.Post))
        {
        <table>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Name, "DisplayFor / EditFor Name")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.Name)'
                </td>
                <td>
                    @Html.EditorFor(model => model.Name)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Dependent.Name, "DisplayFor / EditFor Dependent.Name")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.Dependent.Name)'
                </td>
                <td>
                    @Html.EditorFor(model => model.Dependent.Name)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Alive, "DisplayFor / EditFor Alive")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.Alive)'
                </td>
                <td>
                    @Html.EditorFor(model => model.Alive)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Dependent.Alive, "DisplayFor / EditFor Dependent.Alive")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.Dependent.Alive)'
                </td>
                <td>
                    @Html.EditorFor(model => model.Dependent.Alive)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Age, "DisplayFor / EditFor Age")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.Age)'
                </td>
                <td>
                    @Html.EditorFor(model => model.Age)
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.GPA, "DisplayFor / EditFor GPA")
                </td>
                <td>
                    '@Html.DisplayFor(model => model.GPA)'
                </td>
                <td>
                    @Html.EditorFor(model => model.GPA)
                </td>
            </tr>
        </table>
        }
    </div>

    <div style="float: left; border: 5px solid darkseagreen; margin: 5px; padding: 7px;">
        @Html.DisplayForModel()
    </div>
    <div style="float: left; border: 5px dotted darkgreen; margin: 5px; padding: 7px">
        @Html.EditorForModel()
    </div>
</div>
